// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  if(event.state == "成功") {
    return cloud.database().collection("signUp").doc(event._id).update({
      data: {
        state: event.state
      },
      success: sres => {
        console.log("修改报名状态成功", sres)
      },
      fail: sres => {
        console.log("修改报名状态失败", sres)
      }
    })
  } else {
    return cloud.database().collection("signUp").doc(event._id).update({
      data: {
        state: event.state,
        contestant_id: ""
      },
      success: sres => {
        console.log("修改报名状态成功", sres)
      },
      fail: sres => {
        console.log("修改报名状态失败", sres)
      }
    })
  }
    
}